import { useRoutes } from "react-router-dom";
import { useState } from "react";
import routes from "@/routes/router.jsx";
import LoginPage from './LoginPage.jsx';

function Login() {
  const element = useRoutes(routes);
  const [isLoggedIn, setIsLoggedIn] = useState(false);

  if (!isLoggedIn) {
    // 未登录时显示登录页，不显示路由内容
    console.log("未登录");
    return <LoginPage onLogin={() => setIsLoggedIn(true)} />;
  }

  // 已登录时显示路由内容
  return <>{element}</>;
}


export default Login;